<!DOCTYPE html>
<html lang="en">
<head>
    <meta name="renderer" content="webkit">
    <meta content="IE=Edge" http-equiv="X-UA-Compatible">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <title>登录</title>
    <link rel="stylesheet" type="text/css" href="css/login.css">
    <script src="/js/jquery-1.9.1.js"></script>
    <script src="js/vue.min.js"></script>
    <script src="js/axios.min.js"></script>

</head>
<body>
<div id="bgBox">
    <div id="loginBox" class="logWrap">
        <h2 class="logTitle">登录</h2>
        <div class="formInput">
            <span>账号</span>
            <input placeholder="请输入账号" type="text" id="username" name="username" maxlength="25"/>
            <span id="tips1"
                  style="color:red; font-size:12px;position: absolute;width:100%;text-align: left;margin-top:39px;margin-left: 90px;"></span>
        </div>
        <div class="formInput">
            <span>密码</span>
            <input placeholder="请输入密码" type="password" name="password" id="password" maxlength="16"
                   onkeyup="this.value=this.value.replace(/[^\w]/g,'');"/>
            <span id="tips2"
                  style="color:red; font-size:12px;position: absolute;width:100%;text-align: left;margin-top:39px;margin-left: 90px;"></span>
        </div>
        <div class="certainBtn formInput">
            <button type="button" id="login" onclick="login()">登录</button>
        </div>
    </div>
</body>
<script type="text/javascript">
    function login() {
        let username = $.trim($("#username").val());
        let password = $.trim($("#password").val());
        axios.post("/login?username=" + username + "&password=" + password).then(function (res) {
            if (res.data.code == 200) {
                localStorage.setItem("username",username);
                location.href = "index.html";
            } else if (res.data.code == 500) {

            }
        }).catch(function (err) {

        })
    }
</script>
</html>
